package com.cyys.modules.system.service.file;

import com.cyys.common.ql.AR;
import com.cyys.common.services.CyysBaseService;
import com.cyys.common.utils.StringUtil;
import com.cyys.modules.system.dao.file.FileDirDao;
import com.cyys.modules.system.model.file.FileDir;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service("fileDirService")
@Transactional(readOnly = true)
public class FileDirService extends CyysBaseService<FileDirDao, FileDir> {

    @Resource
    FileEntryService fileEntryService;

    /**
     * 删除文件目录，并移动文件
     * @param id
     * @return
     * @
     */
    @Transactional(readOnly = false)
    public AR deleteById(String id) {
        if (StringUtil.isBlank(id)){
            return AR.failed("ID为空");
        }else{
            fileEntryService.moveAllFile(id);
            dao.deleteById(id);
            return AR.ok("删除成功");
        }
    }

}
